<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
namespace GLS\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Adapter\DbTable as DbTableAuthAdapter;

class IndexController extends AbstractActionController {
	protected $form;
	protected $authservice;
	public function getAuthService() {
		if (! $this->authservice) {
			$this->authservice = $this->getServiceLocator ()->get ( 'AuthService' );
		}
		return $this->authservice;
	}
	public function indexAction() {
		if ($this->getAuthService ()->getIdentity ()) {
			$userinfo = $this->getAuthService ()->getStorage ()->read ();
			if (! $userinfo->ROLE == 'admin') {
				return $this->redirect ()->toRoute ( 'Login' );
			}
			$viewmodel = new ViewModel ();
			$this->layout ()->role = $userinfo->ROLE;
			$this->layout ()->user = $userinfo->USERNAME;
			return $viewmodel;
		}
		
		return $this->redirect ()->toRoute ( 'Login' );
	}
	
	public function getUpcomingEventStatus() {
		$data = null;
		
		//query to get percentage value of available and registered seats for pie chart.
		
		return $data;
	}
	
	private function getPreviousEventData() {
		$data = null;
		
		//query to get number of participants for last 5 completed events
		
		return $data;
	}
}
